package com.service.impl;

import com.dao.GroupMessageDao;
import com.entity.GroupMessage;
import com.service.GroupMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GroupMessageServiceImpl implements GroupMessageService {
    @Autowired
    private GroupMessageDao groupMessageDao;
    @Override
    public List<GroupMessage> getByGroupId(Integer groupId) {
        return groupMessageDao.getByGroupId(groupId);
    }

    @Override
    public List<GroupMessage> getAllByGroupId(Integer pageNum,Integer pageSize,Integer groupId) {
        return groupMessageDao.getAllByGroupId(pageNum,pageSize,groupId);
    }

    @Override
    @Transactional
    public GroupMessage addGroupMessage(GroupMessage groupMessage) {
         groupMessageDao.addGroupMessage(groupMessage);
         return groupMessageDao.getById(groupMessage.getId());
    }

    @Override
    public void editBackById(Integer id) {
        groupMessageDao.editBackById(id);
    }
}
